<?php
	class VideotypeAction extends AdminAction{
		//视频类型设置页面
		public function index(){
			$videotype=M('Videotype');
			$res=$videotype->select();
			$num=count($res);
			for($i=0;$i<$num;$i++){
				$res[$i]['html']=$res[$i]['html']?'√':'×';
			}

			$this->assign('list',$res);
			$this->display();
		}

		public function add(){
			$this->display();
		}

		public function adding(){

			$videotype=D('Videotype');

			if(!$videotype->create()){
				$this->error($videotype->getError());
			}else{
				$res=$videotype->add($_POST);

				if($res){
					$this->success('添加成功','index');
				}else{
					$this->error('添加失败');
				}
			}
		}

		public function edit(){
			$videotype=M('Videotype');
			$list=$videotype->where(array('id'=>$_GET['id']))->find();
			$list['html']=stripslashes($list['html']);
			$this->assign('list',$list);
			$this->display();
		}

		public function editing(){
			$videotype=D('Videotype');

			if(!$videotype->create()){
				$this->error($videotype->getError());
			}else{
				$res=$videotype->where(array('id'=>$_POST['id']))->save($_POST);
				if($res){
					$this->success('编辑成功',index);
				}else{
					$this->error('编辑失败');
				}
			}
		}

		public function del(){
			$videotype=M('Videotype');
			$res=$videotype->where(array('id'=>$_GET['id']))->delete();
			if($res){
				$this->success('删除成功');
			}else{
				$this->error('删除失败');
			}
		}


	}